package com.flykoc.lightinggem.command.subcommand;

import com.flykoc.lightinggem.Entry;
import com.flykoc.lightinggem.dao.GemDao;
import com.flykoc.lightinggem.util.SubCommand;
import org.bukkit.command.CommandSender;

/**
 * @author Zoyn
 * @since 2017-10-22
 */
public class ReloadCommand implements SubCommand {

    @Override
    public void execute(CommandSender sender, String[] args) {
        if (sender.isOp()) {
            // 重载config
            Entry.getInstance().reloadConfig();

            // 清理宝石缓冲
            GemDao.clearMap();
            // 重新读取宝石
            Entry.getInstance().loadGems();
            sender.sendMessage("§a重载成功!");
        } else {
            sender.sendMessage("§c权限不足!");
        }
    }
}
